home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_6.lha / 8_6 / 8_6_fbover.c < prev    next >
Text File  |  1993-08-08  |  648b  |  39 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Empty an output buffer.
  6. include <limits.h>
  7. nt filebuf::overflow(int c)
  8.  
  9.    if (!opened || allocate() == EOF)
  10. return EOF;
  11.  
  12.    // unbuffered IO
  13.    if (base == eptr)
  14. {
  15. if (c != EOF)
  16.     {
  17.     *pptr = c;
  18.     if (putc(c, fp) != c)
  19.     return EOF;
  20.     }
  21. }
  22.  
  23.    // buffered IO
  24.    else
  25. {
  26. if (pptr > base)
  27.     if (fwrite(base, sizeof(char), pptr-base, fp) !=
  28.     pptr-base)
  29.     return EOF;
  30.  
  31. // reset the pointers and store the character
  32. pptr = gptr = base;
  33. if (c != EOF)
  34.     *pptr++ = c;
  35.    }
  36.    return (c & UCHAR_MAX);
  37.  
  38.  
  39.